﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace First_Registry.Ioc
{
    public class ContainerLocator
    {
        private static IContainerExtension _current;
        private static Lazy<IContainerExtension> _lazyContainer;

        public static IContainerExtension Current
        {
            get
            {
                IContainerExtension result;
                if ((result = ContainerLocator._current) == null)
                {
                    Lazy<IContainerExtension> lazyContainer = ContainerLocator._lazyContainer;
                    result = (ContainerLocator._current = ((lazyContainer != null) ? lazyContainer.Value : null));
                }
                return result;
            }
        }

        public static void SetContainerExtension(Func<IContainerExtension> factory)
        {
            ContainerLocator._lazyContainer = new Lazy<IContainerExtension>(factory);
        }
    }
}
